﻿using System;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

internal delegate bool D();
internal delegate bool D2(int i);
public class Lambda : MonoBehaviour
{
    private D del;
    private D2 del2;
    public void TestMethod(int input)
    {
        int j = 0;
        del = () =>
        {
            j = 10;
            return j > input;
        };
        del2 = (x) => { return x == j; };

        Debug.Log(j);
        bool boolResult = del();
        Debug.Log(j+boolResult.ToString());

    }
    void Start()
    {
        
/*        LambdaFun("joy 2013",s=>
        {
            if (s.Contains("2013"))
            {
                s = s.Replace("2013", "2014");
            }
            return s;
        });*/


        Lambda test = new Lambda();
        test.TestMethod(5);
        bool result = test.del2(10);
        Debug.Log(result);

    }
    // Update is called once per frame
    void Update()
    {
        
    }


    void LambdaFun(string str, Func<string, string> func)
    {
        Debug.Log(func(str));
    }


    void _Lambda()
    {

        List<string> names = new List<string>();
        names.Add("joy wang");
        names.Add("joy li");
        names.Add("joy zhang");
        names.Add("lucy li");
        names.Add("jim zhang");

        List<string> found = names.FindAll(name => name.StartsWith("joy", StringComparison.OrdinalIgnoreCase));
        if (found != null)
        {
            foreach (string str in found)
            {
                Debug.Log(str);
            }
        }
    }
}
